package visitor;

import java.util.ArrayList;
import java.util.Iterator;

public class FileFindVisitor extends Visitor {
    private ArrayList<File> foundFiles = new ArrayList<>();

    public ArrayList<File> getFoundFiles() {
        return foundFiles;
    }

    @Override
    public void visit(File file) {
        if (file.getName().endsWith(".html")) {
            foundFiles.add(file);
        }

    }

    @Override
    public void visit(Directory directory) {
        Iterator<Entry> iterable = directory.iterator();
        while (iterable.hasNext()) {
            Entry entry = iterable.next();
            entry.accept(this);
        }

    }
}
